package com.ruoyi.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.WebIndustryData;
import com.ruoyi.web.service.IWebIndustryDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行业资讯模块Controller
 * 
 * @author li
 * @date 2025-08-01
 */
@Api(tags = "行业资讯模块数据")
@RestController
@RequestMapping("/web/industry")
public class WebIndustryDataController extends BaseController
{
    @Autowired
    private IWebIndustryDataService webIndustryDataService;

    /**
     * 查询行业资讯模块列表
     */
    @ApiOperation("查询行业资讯模块数据列表")
    @PreAuthorize("@ss.hasPermi('web:industry:list')")
    @GetMapping("/list")
    public TableDataInfo list(WebIndustryData webIndustryData)
    {
        startPage();
        webIndustryData.setPageId(String.valueOf(5));
        List<WebIndustryData> list = webIndustryDataService.selectWebIndustryDataList(webIndustryData);
        return getDataTable(list);
    }

    /**
     * 导出行业资讯模块列表
     */
    @PreAuthorize("@ss.hasPermi('web:industry:export')")
    @Log(title = "行业资讯模块", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WebIndustryData webIndustryData)
    {
        List<WebIndustryData> list = webIndustryDataService.selectWebIndustryDataList(webIndustryData);
        ExcelUtil<WebIndustryData> util = new ExcelUtil<WebIndustryData>(WebIndustryData.class);
        util.exportExcel(response, list, "行业资讯模块数据");
    }

    /**
     * 获取行业资讯模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('web:industry:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(webIndustryDataService.selectWebIndustryDataById(id));
    }

    /**
     * 新增行业资讯模块
     */
    @PreAuthorize("@ss.hasPermi('web:industry:add')")
    @Log(title = "行业资讯模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WebIndustryData webIndustryData)
    {
        return toAjax(webIndustryDataService.insertWebIndustryData(webIndustryData));
    }

    /**
     * 修改行业资讯模块
     */
    @PreAuthorize("@ss.hasPermi('web:industry:edit')")
    @Log(title = "行业资讯模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WebIndustryData webIndustryData)
    {
        return toAjax(webIndustryDataService.updateWebIndustryData(webIndustryData));
    }

    /**
     * 删除行业资讯模块
     */
    @PreAuthorize("@ss.hasPermi('web:industry:remove')")
    @Log(title = "行业资讯模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(webIndustryDataService.deleteWebIndustryDataByIds(ids));
    }
}
